﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using IterationLife.Domains.Sports.Dtos.MTDatas;

namespace IterationLife.Domains.Sports.Dtos.MTSports
{
    public class MTGatherLv2
    {
        /// <summary>
        /// 持续时间
        /// </summary>
        public decimal? duration { get; set; }
        /// <summary>
        /// 总跑动距离
        /// </summary>
        public decimal? totalDistance { get; set; }
        /// <summary>
        /// 转向次数
        /// </summary>
        public decimal? turningTimes { get; set; }
        /// <summary>
        /// 冲撞次数
        /// </summary>
        public decimal? bumpTimes { get; set; }
        /// <summary>
        /// 跳跃次数
        /// </summary>
        public decimal? jumpTimes { get; set; }
        /// <summary>
        /// 最快速度
        /// </summary>
        public decimal? speedMax { get; set; }
        /// <summary>
        /// 平均速度
        /// </summary>
        public decimal? speedAvg { get; set; }
        /// <summary>
        /// 最大心率
        /// </summary>
        public decimal? heartRateMax { get; set; }
        /// <summary>
        /// 平均心率
        /// </summary>
        public decimal? heartRateAvg { get; set; }
        /// <summary>
        /// 心率回复
        /// </summary>
        public decimal? heartRateRecovery { get; set; }
        /// <summary>
        /// 平均心率强度
        /// </summary>
        public decimal? loadAvg { get; set; }
        /// <summary>
        /// 最大心率强度
        /// </summary>
        public decimal? loadMax { get; set; }
        /// <summary>
        /// 最大心率强度
        /// </summary>
        public decimal? heartRateIntensityMax { get; set; }
        /// <summary>
        /// 内部负荷/心率负荷
        /// </summary>
        public decimal? trimp { get; set; }
        /// <summary>
        /// 走慢速跑
        /// </summary>
        public decimal? distance1 { get; set; }
        /// <summary>
        /// 低速跑
        /// </summary>
        public decimal? distance2 { get; set; }
        /// <summary>
        /// 中速跑距离
        /// </summary>
        public decimal? distance3 { get; set; }
        /// <summary>
        /// 快速跑距离
        /// </summary>
        public decimal? distance4 { get; set; }
        /// <summary>
        /// 高速跑距离
        /// </summary>
        public decimal? distance5 { get; set; }
        /// <summary>
        /// 冲刺跑距离
        /// </summary>
        public decimal? distance6 { get; set; }
        /// <summary>
        /// 高强度跑距离
        /// </summary>
        public decimal? speed56Distance { get; set; }
        /// <summary>
        /// 高强度跑次数
        /// </summary>
        public decimal? speed56Times { get; set; }
        /// <summary>
        /// 高速跑次数
        /// </summary>
        public decimal? speed5Times { get; set; }
        /// <summary>
        /// 冲刺跑次数
        /// </summary>
        public decimal? speed6Times { get; set; }
        /// <summary>
        /// 高强度跑占比
        /// </summary>
        public decimal? distance56Per { get; set; }
        /// <summary>
        /// 冲刺跑占比
        /// </summary>
        public decimal? distance6Per { get; set; }
        /// <summary>
        /// 冲刺跑间隔
        /// </summary>
        public decimal? speed6Space { get; set; }
        /// <summary>
        /// 高强度跑间隔
        /// </summary>
        public decimal? speed56Space { get; set; }
        /// <summary>
        /// 外部负荷/身体负荷
        /// </summary>
        public decimal? playerLoader { get; set; }
        /// <summary>
        /// 10min最大身体负荷/身体负荷
        /// </summary>
        public decimal? playerLoaderMax10 { get; set; }
        /// <summary>
        /// 1min最大身体负荷
        /// </summary>
        public decimal? playerLoaderMax1 { get; set; }
        /// <summary>
        /// 跑动指数
        /// </summary>
        public decimal? runningIndex { get; set; }
        /// <summary>
        /// 1分钟最大高强度跑距离
        /// </summary>
        public decimal? distance56Max1 { get; set; }
        /// <summary>
        /// 10分钟最大高强度跑距离
        /// </summary>
        public decimal? distance56Max10 { get; set; }
        /// <summary>
        /// 20分钟最大跑动距离
        /// </summary>
        public decimal? distanceMax20 { get; set; }
        /// <summary>
        /// 爆发能力 最高代谢功率
        /// </summary>
        public decimal? maxPmet { get; set; }
        /// <summary>
        /// 平均代谢负荷
        /// </summary>
        public decimal? avgPmet { get; set; }
        /// <summary>
        /// 代谢负荷
        /// </summary>
        public decimal? sumPmet { get; set; }
        /// <summary>
        /// 1分钟最大代谢负荷
        /// </summary>
        public decimal? sumPmetMax1 { get; set; }
        /// <summary>
        /// 评分
        /// </summary>
        public MTScore score { get; set; }
        /// <summary>
        /// 平均5分钟跑动距离
        /// </summary>
        public decimal? totalDistance5Min { get; set; }
        /// <summary>
        /// 速度耐力（总距离） 最高1分钟跑动距离
        /// </summary>
        public decimal? distanceMax1 { get; set; }
        /// <summary>
        /// 最长单次高强度跑距离
        /// </summary>
        public decimal? maxSpeed56Distance { get; set; }
        /// <summary>
        /// 最长单次高强度跑持续时间
        /// </summary>
        public decimal? maxSpeed56Seconds { get; set; }
        /// <summary>
        /// 有效锻炼时间
        /// </summary>
        public decimal? hrAffectSeconds { get; set; }
        /// <summary>
        /// 有效锻炼时间占比
        /// </summary>
        public decimal? hrAffectPercentage { get; set; }
        /// <summary>
        /// 未知
        /// </summary>
        public decimal? loaderPerTrimp { get; set; }
        /// <summary>
        /// 最快加速时间
        /// </summary>
        public decimal? minAccSeconds { get; set; }
        /// <summary>
        /// 最快心率恢复时间
        /// </summary>
        public decimal? minRecoverySeconds { get; set; }
        /// <summary>
        /// 最大1min心率恢复值
        /// </summary>
        public decimal? maxRecovery1Min { get; set; }
        /// <summary>
        /// 运动前心率
        /// </summary>
        public decimal? firstHr { get; set; }
        /// <summary>
        /// 未知
        /// </summary>
        public decimal? tantivyDistance { get; set; }
        /// <summary>
        /// 跑动距离区间占比
        /// </summary>
        public List<MTPercentage> distancePercentage { get; set; }
        /// <summary>
        /// 心率区间占比
        /// </summary>
        public List<MTPercentage> hrMaxPercentage { get; set; }
    }


    public static class MTGatherLv2Extension
    {

        public static MTGatherData ToMTGatherData(this MTGatherLv2 mtGatherLv2)
        {
            MTGatherData result = new MTGatherData();
            /// <summary>
            /// 持续时间
            /// </summary>
            result.TotalSeconds = mtGatherLv2.duration;
            /// <summary>
            /// 总跑动距离
            /// </summary>
            result.TotalDistance = mtGatherLv2.totalDistance;
            /// <summary>
            /// 转向次数
            /// </summary>
            result.TurningTimes = mtGatherLv2.turningTimes;
            /// <summary>
            /// 冲撞次数
            /// </summary>
            result.BumpTimes = mtGatherLv2.bumpTimes;
            /// <summary>
            /// 跳跃次数
            /// </summary>
            result.JumpTimes = mtGatherLv2.jumpTimes;
            /// <summary>
            /// 最快速度
            /// </summary>
            result.SpeedMax = mtGatherLv2.speedMax;
            /// <summary>
            /// 平均速度
            /// </summary>
            result.SpeedAvg = mtGatherLv2.speedAvg;
            /// <summary>
            /// 最大心率
            /// </summary>
            result.HeartRateMax = mtGatherLv2.heartRateMax;
            /// <summary>
            /// 平均心率
            /// </summary>
            result.HeartRateAvg = mtGatherLv2.heartRateAvg;
            /// <summary>
            /// 心率回复
            /// </summary>
            result.HeartRateRecovery = mtGatherLv2.heartRateRecovery;
            /// <summary>
            /// 平均心率强度
            /// </summary>
            result.LoadAvg = mtGatherLv2.loadAvg;
            /// <summary>
            /// 最大心率强度
            /// </summary>
            result.LoadMax = mtGatherLv2.loadMax;
            /// <summary>
            /// 最大心率强度
            /// </summary>
            result.HeartRateIntensityMax = mtGatherLv2.heartRateIntensityMax;
            /// <summary>
            /// 内部负荷/心率负荷
            /// </summary>
            result.Trimp = mtGatherLv2.trimp;
            /// <summary>
            /// 走慢速跑
            /// </summary>
            result.Distance1 = mtGatherLv2.distance1;
            /// <summary>
            /// 低速跑
            /// </summary>
            result.Distance2 = mtGatherLv2.distance2;
            /// <summary>
            /// 中速跑距离
            /// </summary>
            result.Distance3 = mtGatherLv2.distance3;
            /// <summary>
            /// 快速跑距离
            /// </summary>
            result.Distance4 = mtGatherLv2.distance4;
            /// <summary>
            /// 高速跑距离
            /// </summary>
            result.Distance5 = mtGatherLv2.distance5;
            /// <summary>
            /// 冲刺跑距离
            /// </summary>
            result.Distance6 = mtGatherLv2.distance6;
            /// <summary>
            /// 高强度跑距离
            /// </summary>
            result.Speed56Distance = mtGatherLv2.speed56Distance;
            /// <summary>
            /// 高强度跑次数
            /// </summary>
            result.Speed56Times = mtGatherLv2.speed56Times;
            /// <summary>
            /// 高速跑次数
            /// </summary>
            result.Speed5Times = mtGatherLv2.speed5Times;
            /// <summary>
            /// 冲刺跑次数
            /// </summary>
            result.Speed6Times = mtGatherLv2.speed6Times;
            /// <summary>
            /// 高强度跑占比
            /// </summary>
            result.Distance56Per = mtGatherLv2.distance56Per;
            /// <summary>
            /// 冲刺跑占比
            /// </summary>
            result.Distance6Per = mtGatherLv2.distance6Per;
            /// <summary>
            /// 冲刺跑间隔
            /// </summary>
            result.Speed6Space = mtGatherLv2.speed6Space;
            /// <summary>
            /// 高强度跑间隔
            /// </summary>
            result.Speed56Space = mtGatherLv2.speed56Space;
            /// <summary>
            /// 外部负荷/身体负荷
            /// </summary>
            result.PlayerLoader = mtGatherLv2.playerLoader;
            /// <summary>
            /// 10min最大身体负荷/身体负荷
            /// </summary>
            result.PlayerLoaderMax10 = mtGatherLv2.playerLoaderMax10;
            /// <summary>
            /// 1min最大身体负荷
            /// </summary>
            result.PlayerLoaderMax1 = mtGatherLv2.playerLoaderMax1;
            /// <summary>
            /// 跑动指数
            /// </summary>
            result.RunningIndex = mtGatherLv2.runningIndex;
            /// <summary>
            /// 1分钟最大高强度跑距离
            /// </summary>
            result.Distance56Max1 = mtGatherLv2.distance56Max1;
            /// <summary>
            /// 10分钟最大高强度跑距离
            /// </summary>
            result.Distance56Max10 = mtGatherLv2.distance56Max10;
            /// <summary>
            /// 20分钟最大跑动距离
            /// </summary>
            result.DistanceMax20 = mtGatherLv2.distanceMax20;
            /// <summary>
            /// 爆发能力 最高代谢功率
            /// </summary>
            result.MaxPmet = mtGatherLv2.maxPmet;
            /// <summary>
            /// 平均代谢负荷
            /// </summary>
            result.AvgPmet = mtGatherLv2.avgPmet;
            /// <summary>
            /// 代谢负荷
            /// </summary>
            result.SumPmet = mtGatherLv2.sumPmet;
            /// <summary>
            /// 1分钟最大代谢负荷
            /// </summary>
            result.BumpTimes = mtGatherLv2.sumPmetMax1;
            /// <summary>
            /// 评分
            /// </summary>
            result.Score = mtGatherLv2.score?.score;
            result.ScoreAll = mtGatherLv2.score?.scoreAll;
            result.Score56 = mtGatherLv2.score?.score56;
            /// <summary>
            /// 平均5分钟跑动距离
            /// </summary>
            result.TotalDistance5Min = mtGatherLv2.totalDistance5Min;
            /// <summary>
            /// 速度耐力（总距离） 最高1分钟跑动距离
            /// </summary>
            result.DistanceMax1 = mtGatherLv2.distanceMax1;
            /// <summary>
            /// 最长单次高强度跑距离
            /// </summary>
            result.MaxSpeed56Distance = mtGatherLv2.maxSpeed56Distance;
            /// <summary>
            /// 最长单次高强度跑持续时间
            /// </summary>
            result.MaxSpeed56Seconds = mtGatherLv2.maxSpeed56Seconds;
            /// <summary>
            /// 有效锻炼时间
            /// </summary>
            result.HrAffectSeconds = mtGatherLv2.hrAffectSeconds;
            /// <summary>
            /// 有效锻炼时间占比
            /// </summary>
            result.HrAffectPercentage = mtGatherLv2.hrAffectPercentage;
            /// <summary>
            /// 未知
            /// </summary>
            result.LoaderPerTrimp = mtGatherLv2.loaderPerTrimp;
            /// <summary>
            /// 最快加速时间
            /// </summary>
            result.MinAccSeconds = mtGatherLv2.minAccSeconds;
            /// <summary>
            /// 最快心率恢复时间
            /// </summary>
            result.MinRecoverySeconds = mtGatherLv2.minRecoverySeconds;
            /// <summary>
            /// 最大1min心率恢复值
            /// </summary>
            result.MaxRecovery1Min = mtGatherLv2.maxRecovery1Min;
            /// <summary>
            /// 运动前心率
            /// </summary>
            result.FirstHr = mtGatherLv2.firstHr;
            /// <summary>
            /// 未知
            /// </summary>
            result.TantivyDistance = mtGatherLv2.tantivyDistance;

            if (mtGatherLv2.distancePercentage != null)
            {
                result.DistancePercentage = mtGatherLv2.distancePercentage.Select(t => t.ToMtPercentageData()).ToList();
            }
            if (mtGatherLv2.hrMaxPercentage != null)
            {
                result.HrMaxPercentage = mtGatherLv2.hrMaxPercentage.Select(t => t.ToMtPercentageData()).ToList();
            }
            return result;
        }
    }
}